home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / asm32.zip / GRAPHICS.DOC < prev    next >
Text File  |  1995-11-28  |  87KB  |  2,480 lines

  1.  
  2. ****************************** GRAPHICS *************************************
  3.  
  4. ASM32 Graphics (C) Copyright 1993 - 1995 Douglas Herr ■ All rights reserved
  5.  
  6. ASM32 recognizes and automatically supports several graphics modes,
  7. including several which are not recognized by IBM's BIOS.  You should
  8. assume that all ASM32 graphics subroutines write directly to the video
  9. hardware.
  10.  
  11. Locations on Graphics screens are defined by coordinate pairs such as (x,y).
  12. X-coordinates are the horizontal dimensions of the screen, and Y-coordinates
  13. are the vertical coordinates.  X = 0 is the at the left edge of the screen,
  14. and X = 719 is the right edge of a Hercules screen, while Y = 0 is the top
  15. edge of the screen and Y = 347 is the bottom (Hercules).  Thus, the
  16. coordinate specified by (719,0) is the extreme upper right corner of a
  17. Hercules screen.
  18.  
  19. Graphics subroutines as powerful and flexible as ASM32's can be quite
  20. large.  If you have licenced ASM32 source code, you can use several
  21. pre-defined conditional assembly directives to eliminate code from
  22. ASM32 object files if you do not want or need to support all graphics
  23. modes:
  24.  
  25.         NOHERC      eliminates all Hercules and InColor code
  26.         NOINCOLOR   eliminates code for the InColor card
  27.                (InColor works with Hercules monochrome code in 2 colors)
  28.         NO256       eliminates code for 256-color modes
  29.         NOCGA       eliminates code for CGA graphics modes
  30.         EGA         assembles only instructions for the EGA/VGA-type
  31.                     16-color modes or better.
  32.  
  33. If you want to support only 16-color EGA/VGA-type modes, or better, you may
  34. also use the EGA32CW.LIB or EGA32DP.LIB library to eliminate much of the code
  35. and data required for monochrome, InColor, and CGA modes.  The EGA32 libraries
  36. can eliminate several thousand bytes from your executable files.
  37.  
  38. Example:
  39.  
  40. (CauseWay)
  41. WL32 mycode+startcw,,,EGA32CW+ASM32CW
  42.  
  43. (DPMI, MS-LINK)
  44. LINK startdp+mycode,,,EGA32DP+ASM32DP
  45.  
  46. (DPMI, TLINK)
  47. TLINK /3 startdp+mycode,,,EGA32DP+ASM32DP
  48.  
  49. When using the EGA32 library, EGA32 must appear before ASM32 on the
  50. command line so that the linker uses the subroutines in EGA32 instead of
  51. the general subroutines in ASM32.
  52.  
  53. EGA32 libraries are provided with standard ASM32 registration.
  54.  
  55.  
  56. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  57.  
  58. Graphics modes and pages supported are:
  59.  
  60. Mode           Maximum x   Maximum y   Colors  Pages (1)  Equipment
  61.                 ("xmax")    ("ymax")
  62.  
  63. HGraph           719          347       2         0, 1    HGC, HGC+ (2)
  64. HGraph           719          347      16         0, 1    InColor  (2)
  65. 04h, 05h         319          199       4         0       CGA, EGA, MCGA, VGA
  66. 06h              639          199       2         0       CGA, EGA, MCGA, VGA
  67. 0Dh              319          199       16        0 - 7   EGA, VGA  (3)
  68. 0Eh              639          199       16        0 - 3   EGA, VGA  (3)
  69. 0Fh              639          349       4         0       EGA, VGA  (4)
  70. 10h              639          349       16        0, 1    EGA, VGA  (3,5)
  71. 11h              639          479       2         0       MCGA, VGA, SVGA
  72. 12h              639          479       16        0       VGA, SVGA
  73. 13h              319          199       256       0       MCGA, VGA, SVGA
  74. 40h              639          399       2         0       ATT 6300
  75. 6Ah              799          599       16        0       VESA  (6)
  76. XMode16      up to 799     up to 599    16        0       Super EGA/VGA
  77. VGA13X      319 or 359    199 to 479    256       (7)     VGA
  78. SVGA16      799 or 1023   599 or 767    16        (10)    Super VGA (8)
  79. SVGA256     639 to 1023   399 to 767    256       (10)    Super VGA (8)
  80. GScreen (9)    no hardware limit        256       0       MCGA, VGA, SVGA
  81. SVGA32k     319 to 1280   199 to 1024   32k       (10)    Super VGA (8)
  82.  
  83. (1)  page numbering begins with page 0.  Several modes have sufficient
  84.      memory available for additional page(s).
  85. (2)  page 1 available after calling Use64k
  86. (3)  EGA pages assumes 256k EGA memory
  87. (4)  monochrome monitor only
  88. (5)  EGA with 128k or more memory
  89. (6)  VESA mode 6Ah is supported by many Super VGA cards with multi-frequency
  90.      monitors
  91. (7)  VGA13X pages available range from 0 to 3.  See VGA13X in MODE.DOC.
  92. (8)  requires VGAKIT-compatible Super VGA and multi-frequency monitor.  See
  93.      SVGA16 and SVGA256 in MODE.DOC.
  94. (9)  a GScreen video buffer may be any dimension you want, as long as you
  95.      can allocate the memory required from RAM.  See UseGScreen.  MCGA is
  96.      minimum hardware required to display the image.  Only one page per
  97.      GScreen, but multiple GScreens may be allocated at any time.
  98. (10) SVGA modes allow multiple pages if a VESA BIOS is installed.
  99.  
  100. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  101.  
  102. $SetFontData:  change character set used by ASM32's GPRINT subroutines
  103. Source:        fontdata.asm
  104.  
  105. Call with:     EBX = character set index
  106.                  0 = use standard 8x8 characters
  107.                  1 = use standard 8x14 characters
  108.                  2 = user-suplied character font:
  109.                      FS:EAX = far address of character font data
  110.                      DH = bytes from one character's data to the next
  111.                      DL = byte size of each character (must be <= DH)
  112.  
  113. Returns:       nothing
  114. Uses:          EBX
  115. Example:       see GPRINT
  116.  
  117.  
  118. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  119.  
  120. BB16MASK:      create reverse mask from 16-color bitblock
  121. Source:        bb16mask.asm ($graph.asm)
  122.  
  123. Call with:     ES:[EDI] pointing to 2- or 16-color bitblock
  124.  
  125.                BB16MASK is handy for situations where you have an image
  126.                stored as a bitblock that contains blank areas that are not
  127.                part of the image, and you want to overlay the image on a
  128.                pre-existing screen image.  BB16MASK creates a reverse-image
  129.                mask that you may use to clear a space in the pre-existing
  130.                screen image in order to put the bitblock on the screen.
  131.                The effect is similar to using drawmode 2 with 256-color
  132.                bitblocks.  PutBitBlock with 16-color modes does not
  133.                support drawmode 2.  See example.
  134.  
  135. Returns:       if CF = 0, ES:[EDI] points to new reverse-mask bitblock
  136.                if CF = 1, a memory allocation error was encountered
  137. Uses:          ES, EDI, flags
  138. Supports:      2-color and 16-color bitblocks, and EGA mode 0Fh 4-color
  139.                bitblocks.
  140. See also:      GetBitBlock, PutBitBlock
  141.  
  142. Example on next page
  143.  
  144. Example:
  145.  
  146. ; I have an image of Peter Pan that I want to show flying across a
  147. ; a background image.
  148.  
  149. ; assume that the background image is in place
  150.  
  151. extrn   putbitblock:proc
  152. extrn   bb16mask:proc
  153.  
  154. include dataseg.inc
  155. extrn   drawmode:byte
  156. PeterPan    dw ?               ; segment address of Peter Pan image
  157.                                ; actual address filled in by the program
  158. PPMask      dw ?               ; storage area for inverse mask
  159. peterpan_xy dw ?,?             ; coordinates to put Peter Pan
  160.                                ; filled in by program
  161.  
  162. include codeseg.inc
  163. ; program fragment assumes 16-color graphics mode
  164.         .
  165.         .
  166.         .
  167.         mov     es,PeterPan
  168.         xor     edi,edi        ; ES:[EDI] points to Peter Pan bitblock
  169.         call    bb16mask       ; returns ES:[EDI] pointing to mask bitblock
  170.         jc      cant_do_it     ;  do error control
  171.         mov     PPMask,es      ; save mask address - DI is always zero
  172.         .
  173.         .
  174.         .
  175. ; some time later...
  176. ;
  177. ; make space for PeterPan bitblock
  178. ;
  179.         mov     drawmode,4     ; AND mode
  180.         lea     ebx,peterpan_xy
  181.         mov     es,PPMask
  182.         xor     edi,edi        ; ES:[EDI] points to mask image
  183.         call    putbitblock    ; clear a space for Peter Pan
  184.  
  185.         mov     drawmode,3     ; OR the Peter Pan image into cleared space
  186.         mov     es,PeterPan
  187.         xor     edi,edi
  188.         call    putbitblock
  189.  
  190.  
  191. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  192.  
  193. BB16REV:       reverses a 2-color or 16-color bitblock saved by GetBitBlock
  194.  
  195. Source:        bb16rev.asm
  196.  
  197. Call with:     [EDI] = near pointier to bit block
  198.  
  199.                BB16REV reverses the image left-to-right in any 2-color
  200.                or 16-color bitblock saved by GetBitBlock.
  201.                Also works with EGA monochrome (mode 0Fh) bitblocks.
  202.                Assumes that the system is in the graphics mode used to
  203.                create the bitblock.
  204.  
  205. Returns:       nothing
  206. Uses:          flags
  207. Supports:      all ASM32 2-color, 16-color and EGA monochrome bit blocks
  208. See also:      GetBitBlock, PutBitBlock
  209. Example:       See example for BB256REV.
  210.  
  211.  
  212.  
  213. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  214.  
  215. BB256OVL:      overlay one 256-color bitblock on another
  216. Source:        bb256ovl.asm
  217.  
  218. Supports:      256-color bitblocks created with ASM32's GetBitBlock.  You
  219.                may also use 256-color screen image data created by ASM32's
  220.                GetGScreen.
  221.                256-color modes are mode 13h, VGA13x and SVGA256.
  222.  
  223. Call with:     DS:[ESI] pointing to source bitblock
  224.                ES:[EDI] pointing to destination bitblock
  225.                AX = signed x-offset of source in destination
  226.                BX = signed y-offset of source in destination
  227.  
  228.                Non-zero pixels in the source bitblock is copied to the
  229.                destination bitblock.  Source and destination bitblocks
  230.                need not be the same size.  If x-width of source plus x-
  231.                offset is greater than x-width of destination, the source
  232.                will be clipped at the right edge of the destination bitblock.
  233.                Similarly, if the y-height of the source bitblock plus the y-
  234.                offset is greater than the y-height of the destination, the
  235.                source is clipped at the bottom of the destination bitblock.
  236.                X- and y-offsets may be negative; if so, the left or top of
  237.                the source is clipped at the left or top of the destination.
  238.                If both x-offset and y-offset are zero, the upper-left
  239.                corner of the source is overlayed on the upper-left corner
  240.                of the destination bitblock.  In all cases the source
  241.                is not changed.
  242.  
  243.                This subroutine is handy for some animation techniques.  In
  244.                this case, a background bitblock and one or more foreground
  245.                object bitblocks are developed; a copy of the background is
  246.                made, and is used as the destination bitblock; then, the
  247.                various foreground bitblocks are added to the background at
  248.                whatever location in the background is required by the
  249.                program; finally, the destination bitblock is moved to the
  250.                screen either by ASM32's PutBitBlock or PutGScreen subroutine.
  251.                This keeps most of the bitblock operations in the computer's
  252.                fastest memory and requires only one access to slower video RAM.
  253.  
  254. BB256OVL example begins on next page
  255.  
  256.  
  257. BB256OVL Example:
  258.  
  259. ; I want to show the view from a train on the Alaska Railroad.  I'll use
  260. ; bitblocks for Sky, Sun, Mountains, far trees, meadows, and near trees.
  261. ; This example shows how you would build one image.  To create the illusion
  262. ; of motion, the program would move the near trees faster than the meadow,
  263. ; which is moving faster than the far trees, which are moving faster than
  264. ; the mountains.  Changing the x-offset of each foreground bitblock moves
  265. ; that object against the background.
  266.  
  267. ; uninitialized data in example code is filled in by program before this
  268. ; code executes
  269.  
  270. include dataseg.inc
  271.  
  272. extrn   drawmode:byte
  273. xandy   dw ?,?
  274. ;
  275. ; all bitblocks are in near memory
  276. ;
  277. sky             dd ?            ; near address of background
  278. skysize         dd ?            ; size of background bitblock < 64k
  279. skycopy         dd ?            ; working buffer for building complete image
  280.  
  281. mtns            dd ?            ; near address of mountains bitblock
  282. mtns_offset     dw ?,?          ; offset of mountains in background
  283.  
  284. fartrees        dd ?            ; near address of far trees
  285. fartree_offset  dw ?,?          ; offset of far trees in background
  286.  
  287. meadow          dd ?            ; near address of meadow
  288. meadow_offset   dw ?,?          ; offset of meadow in background
  289.  
  290. neartrees       dd ?            ; near address of near trees
  291. neartree_offset dw ?,?          ; offset of near trees in background
  292.  
  293. include codeseg.inc
  294. ; program fragment assumes 256-color graphics mode
  295.         .
  296.         .
  297. ;
  298. ; start building image by making blank copy of background
  299. ;
  300.         mov     edi,skycopy     ; ES:[EDI] points to working buffer
  301.         mov     ecx,skysize
  302.         mov     esi,sky
  303.         cld
  304.         rep     movsb           ; copy sky bitblock to working buffer
  305.  
  306. ; Example continues on next page
  307.  
  308.  
  309. ; BB256OVL example, continued
  310.  
  311.         mov     edi,skycopy     ; ES:[EDI] points to working background
  312.  
  313. ;
  314. ; add foreground objects to sky
  315. ;
  316.         lea     esi,mtns
  317.         mov     ecx,4           ; 4 foreground bitblocks
  318.  
  319. next_foreground:
  320.         push    esi
  321.  
  322.         mov     ax,4[esi]       ; get x-offset
  323.         mov     bx,6[esi]       ; get y-offset
  324.         mov     esi,[esi]
  325.         call    bb256ovl        ; overlay this bitblock on previous image
  326.         pop     esi             ; get back ptr to bitblock data
  327.         add     esi,8           ; point to next bitblock data
  328.         loop    next_foreground ; do for all bitblocks
  329.  
  330. ;
  331. ; built-up image is complete
  332. ; copy to screen
  333. ;
  334.         mov     drawmode,1      ; I want new image to wipe out old
  335.         lea     ebx,xandy       ; x & y screen address
  336.                                 ; ES:[EDI] still points to working bitblock
  337.         call    putbitblock     ; put bitblock on screen
  338. ;
  339. ; change bitblock offsets to illustrate motion and display next image
  340. ;
  341.         .
  342.         .
  343.         .
  344.         jmp     next_foreground
  345.  
  346.  
  347. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  348.  
  349. BB256REV:      reverses a 256-color bitblock saved by GetBitBlock
  350. Source:        bb256rev.asm
  351.  
  352. Call with:     [EDI] = near pointer to bit block
  353.  
  354.                BB256REV reverses the image left-to-right in any 256-color
  355.                bitblock saved by GetBitBlock.
  356.  
  357. Returns:       nothing
  358. Uses:          flags
  359. Supports:      all ASM32 256-color bit blocks
  360. See also:      GetBitBlock, PutBitBlock
  361.  
  362. Example on next page
  363.  
  364.  
  365. BB256REV Example:
  366.  
  367. ; code fragment assumes e 256-color graphics mode
  368.  
  369. include model.inc
  370.  
  371. extrn   bitblockbytes:near, getbitblock:near, putbitblock:near
  372. extrn   bb256rev:near
  373.  
  374. include dataseg.inc
  375. ptr     dd ?                ; use this to save pointer to bit block
  376. x0      dw 100,43,175,143   ; save from (100,43) to (175,143)
  377. @curseg ends
  378.  
  379. include codeseg.inc
  380.         .
  381.         .
  382.         lea   ebx,x0        ; point to block corners
  383.         call  bitblockbytes ; calculate byte requirement
  384.         jc    too_big       ; error control
  385.         mov   ebx,eax
  386.         sys   GetMemNear
  387.         jc    no_memory     ; more error control
  388.         mov   ptr,esi       ; save near address of bit block
  389.         mov   edi,esi       ; EDI points to buffer
  390.         lea   ebx,x0        ; EBX points to coordinate data
  391.         call  getbitblock
  392.         .
  393.         .
  394.  
  395. ; later . . .
  396. ; reverse the image & put back on screen
  397.         lea   ebx,x0        ; put the bit block back where you found it
  398.         mov   edi,ptr       ; DS:[EDI] points to buffer
  399.         call  bb256rev      ; reverse the image
  400.         call  putbitblock
  401.  
  402.  
  403. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  404.  
  405. BB32kREV:      reverses a 32k-color bitblock saved by GetBitBlock
  406. Source:        bb32krev.asm
  407.  
  408. Call with:     [EDI] = near pointer to bit block
  409.  
  410.                BB32kREV reverses the image left-to-right in any 32k-color
  411.                bitblock saved by GetBitBlock.
  412.  
  413. Returns:       nothing
  414. Uses:          flags
  415. Supports:      all ASM32 32k-color bit blocks
  416. See also:      GetBitBlock, PutBitBlock
  417.  
  418. Example:       See BB256REV
  419.  
  420.  
  421.  
  422. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  423.  
  424. BEZIER:        draw a Bezier curve on the screen
  425. Source:        bezier.asm (drawline.asm)
  426.  
  427. 80x87 or emulator required
  428.  
  429. Call with:     EBX pointing to curve coordinate data
  430.                ECX = number of points on curve (ECX > 0)
  431.                 a larger number of points on the curve will result in
  432.                 slower operation and a smoother curve.  In many cases
  433.                 ECX > 50 will not improve the appearance of the curve.
  434.  
  435.                 Four coordinates are required: two curve endpoints and
  436.                 two control points.  The curve endpoints (x0, y0) and
  437.                 (x3, y3) are similar to DrawLine's coordinates; if you
  438.                 call bezier with ECX = 1, you will see only a straight
  439.                 line between the endpoints.  The "control points" act
  440.                 like magnets, pulling the curve away from a straight line.
  441.                 At each endpoint, the curve is tangent to a line drawn
  442.                 between the endpoint and the adjacent control point
  443.                 ("adjacent" control point meaning adjacent in the data
  444.                 structure).
  445.  
  446. Returns:       nothing
  447. Uses:          all 80x87 registers
  448. Supports:      all ASM32 graphics modes; drawmode 0 not recommended
  449. Example:
  450.  
  451. include codeseg.inc
  452.  
  453. extrn   bezier:near
  454.  
  455. ; data
  456. extrn   drawmode:byte
  457. bz      dw 50,50            ; first endpoint:       (x0, y0)
  458.         dw 100,0            ; first control point:  (x1, y1)
  459.         dw 200,0            ; second control point: (x2, y2)
  460.         dw 250,175          ; second endpoint:      (x3, y3)
  461.                             ; note that both control points in this
  462.                             ; example pull the curve toward the top of the
  463.                             ; screen
  464.  
  465. ; code
  466. ; program fragment assumes 80x87 is installed
  467. ; and that the screen is in graphics mode
  468.         .
  469.         .
  470.         mov     drawmode,1  ; use foreground color
  471.         lea     ebx,bz      ; point to bezier curve data
  472.         mov     ecx,100     ; should be adequate
  473.         call    bezier
  474.  
  475.  
  476.  
  477. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  478.  
  479. BITBLOCKBYTES: calculate bytes required to save a bit block
  480. Source:        bbbytes.asm ($graph.asm)
  481.  
  482. Call with:     EBX pointing to x- and y-coordinate data (see example)
  483. Returns:       EAX = bytes required to save the bit block
  484. Uses:          EAX, flags
  485. Supports:      all ASM32 graphics modes; call BitBlockBytes while
  486.                the system is in the mode you intend to use.  Otherwise,
  487.                an incorrect byte size may be returned, leading to either
  488.                wasted memory or memory allocation errors.
  489. Example:
  490.  
  491. include codeseg.inc
  492.  
  493. extrn   bitblockbytes:near
  494.  
  495. ; data
  496. x0      dw 100,43         ; first corner at (100,43)
  497. x1      dw 175,143        ; second corner at (175,143)
  498.  
  499. ; code
  500.         .
  501.         .
  502.         .
  503.         lea    ebx,x0          ; EBX points to bit block corner data
  504.         call   bitblockbytes   ; returns EAX = byte size of buffer required
  505.  
  506.  
  507.  
  508. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  509.  
  510. BITPLANEBYTES: calculate bytes to save one plane of a bit block
  511.                alternate entry to BitBlockBytes; calculates bytes
  512.                required to save one plane of multi-plane modes
  513. Source:        bbbytes.asm ($graph.asm)
  514. Call with:     EBX pointing to x- and y-coordinate data
  515. Returns:       EAX = bytes required to save the bit plane
  516. Uses:          EAX, flags
  517. Supports:      all ASM32 graphics modes; call BitPlaneBytes while
  518.                the system is in the mode you intend to use.  If the
  519.                system is is not in a multi-plane mode, BitPlaneBytes
  520.                will give you the same results as BitBlockBytes.
  521.                Graphics modes with multiple planes are mode 0Fh (2 planes)
  522.                and all 16-color modes (4 planes).
  523. Example:
  524.  
  525. include codeseg.inc
  526.  
  527. extrn   bitplanebytes:near
  528.  
  529. ; data
  530. x0      dw 100,43         ; first corner at (100,43)
  531. x1      dw 175,143        ; second corner at (175,143)
  532.  
  533. ; code
  534.         .
  535.         .
  536.         .
  537.         lea    ebx,x0          ; EBX points to bit block corner data
  538.         call   bitplanebytes   ; returns EAX = byte size of buffer required
  539.  
  540.  
  541. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  542.  
  543. BUFFERDIM:     change logical buffer dimensions
  544.                does not change number of pixels displayed on screen;
  545.                used with ScreenOrigin.
  546. Source:        buffdim.asm ($graph.asm)
  547.  
  548. Call with:     EBX pointing to new buffer dimensions
  549.                Note that the logical buffer dimensions should be
  550.                greater than the dimensions displayed on the screen
  551.                The logical buffer dimensions must not create a plane size
  552.                greater than 64k; in 16-color modes, a logical pixel width
  553.                of 800 + logical height of 600 works out to 60,000 bytes per
  554.                plane.  In any of the 256-color VGA13x modes, an x-width of
  555.                640 and a y-dimension of 400 is 64,000 bytes per plane.
  556.  
  557.                If anything is displayed on the screen before changing
  558.                logical dimensions, it will be unreadable after calling
  559.                BufferDim if your logical x-dimension is not the same as
  560.                the screen's physical x-width.
  561.  
  562.                BufferDim does no error checking; you must determine if
  563.                the computer has an EGA or VGA (see GetCRT in SYSTEM.DOC)
  564.                and you must verify that the logical dimensions are greater
  565.                than the screen dimensions.
  566.  
  567.                Using BufferDim disables ASM32's multiple graphics pages
  568.                capabilities.
  569.  
  570. Returns:       nothing
  571. Uses:          nothing; all registers and flags are saved
  572. Supports:      EGA/VGA-type 16-color graphics modes
  573.                VGA13x 256-color modes
  574.                VESA SVGA modes
  575. Example:       see next page
  576.  
  577.  
  578.  
  579. (BufferDim example)
  580.  
  581. ; The computer has a 256k EGA card & EGA-only monitor 
  582. ; and I want to display an image that is 800 pixels wide
  583. ; and 600 pixels high.
  584. ; I'll use EGA mode 10h, switch to logical dimensions of 800x600,
  585. ; put the image in the video buffer & use ScreenOrigin to view
  586. ; various parts of the image
  587.  
  588. include codeseg.inc
  589.  
  590. public  mysub
  591. extrn   bufferdim:near, screenorigin:near
  592. extrn   loadpcx:near
  593.  
  594. include model.inc
  595.  
  596. include dataseg.inc
  597.  
  598. dim     dw 800,600              ; I want 800 logical x
  599.                                 ;  & 600 logical y
  600. xy      dw 0,0                  ; screen origin always starts at (0,0)
  601. fname   db '800x600.pcx',0      ; a .PCX file with an 800 x 600 image
  602. @curseg ends
  603.  
  604. include codeseg.inc
  605.  
  606. mysub   proc    near
  607. ; set up 640x350 16-color mode
  608.         mov    ax,10h           ; use BIOS to set mode
  609.         int    10h
  610.         lea    ebx,dim          ; point to logical buffer dimensions
  611.         call   bufferdim        ; set up 800x600 logical dimensions
  612.                                 ; NOTE: only one page available
  613.  
  614. ; program loads image to video buffer
  615.         lea    edx,fname        ; point to filename
  616.         call   loadpcx          ; get image
  617.  
  618. ; default screen origin: (0,0) of buffer is at (0,0) of screen
  619. ; change portion of buffer displayed to logical (100,100)
  620. ; at (0,0) of screen
  621.         lea    ebx,xy
  622.         mov    word ptr [ebx],100
  623.         mov    word ptr 2[ebx],100
  624.         call   screenorigin
  625.  
  626.  
  627. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  628.  
  629. CIRCLEASPECT:  modifies aspect ratio of circle
  630. Source:        $circle.asm ($graph.asm)
  631.  
  632. Call with:     AH = numerator of aspect ratio
  633.                AL = denominator of aspect ratio
  634.                AH <> 0, AL <> 0
  635.  
  636.                CircleAspect is used with DrawCircle to draw an ellipse.
  637.                An aspect ratio less than one makes a flat ellipse and an
  638.                aspect ratio greater than one makes a tall ellipse.
  639.  
  640. Returns:       nothing
  641. Uses:          nothing; all registers and flags are saved
  642. Supports:      all ASM32 graphics modes
  643. Example:       see DrawCircle
  644.  
  645.  
  646.  
  647. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  648.  
  649. COLOR32k:      calculate color attribute for SVGA 32k-color modes
  650. Source:        color32k.asm
  651.  
  652. Call with:     EBX pointing to Red, Green and Blue color bytes
  653.                Red, Green and Blue may range from 0 to 63.  Color32k
  654.                combines these colors in a 15-bit color attribute for
  655.                32k-color graphics modes.
  656. Returns:       AX = color attribute
  657. Uses:          AX; high word of EAX is not changed
  658. Supports:      SVGA 32k-color graphics modes
  659. Example:
  660.  
  661. ; calculate color attributes for background and foreground for 32k-color
  662. ; mode
  663.  
  664. extrn   color32k:near, gcolor:near
  665.  
  666. include dataseg.inc
  667.  
  668. fore    db 32                ; medium red
  669.         db 0                 ; no green
  670.         db 63                ; saturated blue
  671.  
  672. back    db 0                 ; no red
  673.         db 0                 ; no green
  674.         db 32                ; medium blue
  675.  
  676. @curseg ends
  677.  
  678. include codeseg.inc
  679.         .
  680.         .
  681.         .
  682. ; calculate color attributes for foreground & background
  683. ; then pass 'em to GCOLOR
  684.  
  685. ; do background first
  686.         lea     ebx,back
  687.         call    color32k     ; ret: AX = color attribute
  688.         shl     eax,16       ; put background color attribute in place
  689.  
  690. ; now do background
  691.         lea     ebx,fore
  692.         call    color32k     ; ret: AX = foreground color attribute
  693.         call    gcolor
  694.  
  695.  
  696. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  697.  
  698. DEFGMODE:      restore ASM32's internal flags to use system graphics mode
  699.                (see ForceGMode)
  700. Source:        defgmode.asm
  701.  
  702. Call with:     no parameters
  703. Returns:       nothing
  704. Uses:          nothing
  705. Supports:      all ASM32 graphics modes
  706. Example:       see ForceGMode
  707.  
  708.  
  709.  
  710. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  711.  
  712. DRAWCIRCLE:    draw a circle
  713. Source:        drawcirc.asm ($circle.asm, $graph.asm, $putdot.asm)
  714.  
  715. Call with:     EBX pointing to circle center coordinates and x-radius
  716.                Drawmodes supported are:
  717.                 4 = AND the foreground color with the screen
  718.                 3 = OR the foreground color with the screen
  719.                 1, 2 = use foreground color
  720.                 0 = XOR circle with existing screen
  721.                -1, -2 = use background color
  722.                -3 = OR the background color with the screen
  723.                -4 = AND the background color with the screen
  724.                See DrawMode for more information
  725.                See also CircleAspect
  726. Returns:       nothing
  727. Uses:          nothing
  728. Supports:      all ASM32 graphics modes
  729. See also:      FillCircle
  730. Example:
  731.  
  732. include codeseg.inc
  733.  
  734. extrn   drawcircle:near, circleaspect:near
  735.  
  736. ; data
  737. xcenter dw 100              ; DrawCircle data must be words
  738. ycenter dw 100              ; the circle is centered at (100,100)
  739. xradius dw 50               ; x-dimension radius in pixels (>0)
  740.  
  741. ; code
  742.         .
  743.         .
  744.         .
  745.         mov   ah,5
  746.         mov   al,1          ; a tall ellipse
  747.         call  circleaspect
  748.  
  749.         lea   ebx,xcenter   ; EBX points to circle data
  750.         call  drawcircle    ; draw the circle
  751.  
  752.  
  753. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  754.  
  755. DRAWBOX:       draw a rectangle on a graphics screen
  756. Source:        drawbox.asm ($graph.asm, $vert.asm, $horiz.asm, several others)
  757.  
  758. Call with:     EBX pointing to box corner data
  759.                Drawmodes supported are:
  760.                 4 = AND the foreground color with the screen; color modes
  761.                 3 = OR the foreground color with the screen
  762.                 1, 2 = use foreground color: all modes
  763.                 0 = XOR foreground color with existing pixels
  764.                -1, -2 = use background color: all modes
  765.                -3 = OR the background color with the screen
  766.                -4 = AND the background color with the screen; color modes
  767.                See DrawMode for more information; see also LinePattern
  768. Returns:       nothing
  769. Uses:          nothing
  770. Supports:      all ASM32 graphics modes
  771. Example:
  772.  
  773. include codeseg.inc
  774.  
  775. extrn   drawbox:near
  776.  
  777. ; data
  778. x0      dw 25,10            ; first corner at (25,10); data is word size
  779. x1      dw 301,97           ; opposite corner at (301,97)
  780.  
  781. ; code
  782.         .
  783.         .
  784.         lea   ebx,x0         ; EBX points to box corner data
  785.         call  drawbox
  786.  
  787.  
  788. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  789.  
  790. DRAWLINE:      draw a line on a graphics screen
  791. Source:        drawline.asm ($graph.asm, $vert.asm, $horiz.asm,
  792.                              $slope.asm, many others)
  793.  
  794. Call with:     EBX pointing to line endpoint data
  795.  
  796.                Line endpoint data is word data in sets of two (x,y) pairs.
  797.                X and y may vary from -32768 to +32767; only the portion of
  798.                the line that lies with the active View will be displayed.
  799.                See GetView; also see Example.
  800.  
  801.                Drawmodes supported are:
  802.                 4 = AND the foreground color with the screen; color modes
  803.                 3 = OR the foreground color with the screen
  804.                 1, 2 = use foreground color: all modes
  805.                 0 = XOR foreground color with existing pixels
  806.                -1, -2 = use background color: all modes
  807.                -3 = OR the background color with the screen
  808.                -4 = AND the background color with the screen; color modes
  809.                See DrawMode for more information; see also LinePattern
  810. Returns:       nothing
  811. Uses:          nothing
  812. Supports:      all ASM32 graphics modes
  813. Example:
  814.  
  815. extrn   drawline:near
  816.  
  817. include dataseg.inc
  818. x0      dw 25,10            ; first endpoint at (25,10); data is word size
  819. x1      dw 301,97           ; other end of line at (301,97)
  820. @curseg ends
  821.  
  822. include codeseg.inc
  823.         .
  824.         .
  825.         lea   ebx,x0         ; [EBX] points to line coordinate data
  826.         call  drawline
  827.  
  828.  
  829. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  830.  
  831. DRAWMODE:      control ASM32 graphics drawing mode
  832. Source:        $graph.asm
  833.  
  834.                DrawMode is a public byte used to control the operation
  835.                of many ASM32 subroutines.  ASM32's default drawmode is 1.
  836.  
  837.                Typically, drawmodes have the following effects:
  838.                 2 = use foreground color only; text is printed without
  839.                     background, foreground only of line patterns or
  840.                     fill patterns is used
  841.                 1 = use foreground and background; text is printed with
  842.                     background, line patterns and fill patterns update
  843.                     both foreground and background
  844.                 0 = foreground color is XORed with the existing screen
  845.                     (not supported in 256-color or CGA 4-color modes)
  846.                -1 = characters or fill pattern drawn with foreground
  847.                     and background reversed
  848.                -2 = character or line drawn with background color only
  849.  
  850. Supports:      all ASM32 graphics modes
  851. Example:
  852.  
  853. include codeseg.inc
  854.  
  855. ; data
  856. extrn   drawmode:byte
  857.  
  858. ; code
  859.         .
  860.         .
  861.         mov     drawmode,2      ; print text with foreground color only
  862.  
  863.  
  864. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  865.  
  866. FILLAREA:      fills an irregular area on a graphics screen
  867. Source:        fillarea.asm ($graph.asm, $horiz.asm, $getdot.asm,
  868.                              several others)
  869.  
  870. Call with:     EBX pointing to seed pixel coordinates
  871.  
  872.                Fills any irregularly-shaped area with color and/or
  873.                pattern, beginning at (x,y).  The area's boundary is
  874.                defined by a solid line of non-zero pixels.
  875.  
  876.                If you use a FillPattern with FillArea, performance will be
  877.                degraded when using DrawMode 2, or DrawMode 1 with a black
  878.                (color 0) background.  FillArea assumes that all FillPatterns
  879.                are 8 bytes long.
  880.  
  881.                FillArea is a recursive subroutine, and with highly convoluted
  882.                fill regions it uses considerable stack space.  FillArea
  883.                allocates a temporary 64k stack space for this recursive
  884.                process, but under extreme circumstances 64k may not be
  885.                adequate.  FillAreaStack, a public DWORD in FillArea's data
  886.                area, may be increased from the default 64k if nessesary.
  887.                FillArea needs a larger stack if the program jams or crashes
  888.                during a FillArea call.
  889.  
  890.                DrawModes supported are:
  891.                 2 = fill with foreground color only (if fill pattern
  892.                     has been defined): 16-color modes
  893.                 1 = fill with foreground (and background, if fillpattern
  894.                     defined): all modes (FillPattern not supported in 256-
  895.                     color or 32k-color modes).
  896.                See also FillPattern.
  897. Returns:       nothing
  898. Uses:          nothing
  899. Supports:      all ASM32 graphics modes
  900. Example:
  901.  
  902. extrn   fillarea:near
  903.  
  904. include dataseg.inc
  905. extrn   fillareastack:dword
  906. x       dw 10,15         ; start fill operation at x=10, y=15
  907. @curseg ends
  908.  
  909. include codeseg.inc
  910.  
  911.         .
  912.         .
  913.         mov    fillareastack,100000
  914.         lea    ebx,x
  915.         call   fillarea
  916.  
  917.  
  918. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  919.  
  920. FILLBOX:       draw a filled rectangle on a graphics screen
  921. Source:        fillbox.asm ($graph.asm, $horiz.asm, several others)
  922.  
  923. Call with:     EBX pointing to box corner data
  924.                Drawmodes supported are:
  925.                 4 = AND the box with the pre-existing screen
  926.                 3 = OR the foreground color with the screen
  927.                 1, 2 = use foreground color
  928.                 0 = XOR foreground color with existing pixels
  929.                -1, -2 = use background color
  930.                -3 = OR the background color with the screen
  931.                -4 = AND the background color with pre-existing screen
  932.                See DrawMode for more information; also see FillPattern.
  933. Returns:       nothing
  934. Uses:          nothing
  935. Supports:      all ASM32 graphics modes
  936. Example:
  937.  
  938. include codeseg.inc
  939.  
  940. extrn   fillbox:near
  941.  
  942. ; data
  943. x0      dw 25,10            ; first corner at (25,10); data is word size
  944. x1      dw 301,97           ; opposite corner at (301,97)
  945.  
  946. ; code
  947.         .
  948.         .
  949.         lea   ebx,x0         ; [EBX] points to box corner data
  950.         call  fillbox
  951.  
  952.  
  953. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  954.  
  955. FILLCIRCLE:    draw a filled circle
  956. Source:        fillcirc.asm ($circle.asm, $graph.asm, $horiz.asm)
  957.  
  958. Call with:     EBX pointing to circle center coordinates and x-radius
  959.                Drawmodes supported are:
  960.                 4 = AND the foreground color with the screen
  961.                 3 = OR the foreground color with the screen
  962.                 1, 2 = use foreground color
  963.                 0 = XOR circle with existing screen
  964.                -1, -2 = use background color
  965.                -3 = OR the background color with the screen
  966.                -4 = AND the background color with the screen
  967.  
  968. Returns:       nothing
  969. Uses:          nothing
  970. Supports:      all ASM32 graphics modes
  971. See also:      DrawCircle, DrawMode, CircleAspect
  972. Example:
  973.  
  974. include codeseg.inc
  975.  
  976. extrn   fillcircle:near, circleaspect:near
  977.  
  978. ; data
  979. xcenter dw 100              ; fillcircle data must be words
  980. ycenter dw 100              ; the circle is centered at (100,100)
  981. xradius dw 50               ; x-dimension radius in pixels (>0)
  982.  
  983. ; code
  984.         .
  985.         .
  986.         .
  987.         mov   ah,5
  988.         mov   al,1          ; a tall ellipse
  989.         call  circleaspect
  990.  
  991.         lea   ebx,xcenter   ; EBX points to circle data
  992.         call  fillcircle    ; draw the circle
  993.  
  994.  
  995. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  996.  
  997. FILLPATTERN:   define an optional pattern for FillArea & FillBox
  998. Source:        fpattern.asm
  999.  
  1000. Call with:     EBX pointing to ASCIIZ pattern string.
  1001.                Up to 8 characters in the string will be used.
  1002.                The pattern must be re-defined before each call to a line
  1003.                drawing subroutine (FillArea, FillBox).  Note that FillArea
  1004.                uses 8-byte fillpatterns; FillBox allows shorter
  1005.                fillpattern strings.
  1006. Returns:       nothing
  1007. Uses:          nothing
  1008. Supports:      all ASM32 graphics modes except 256-color modes
  1009. Example:
  1010.  
  1011. include codeseg.inc
  1012.  
  1013. extrn   fillbox:near
  1014. extrn   fillpattern:near
  1015.  
  1016. ; data
  1017. x0      dw 25,10            ; first corner at (25,10); data is word size
  1018. x1      dw 301,97           ; opposite corner at (301,97)
  1019. pattern db 8 dup(10101010b),0
  1020.  
  1021. ; code
  1022.         .
  1023.         .
  1024.         lea   ebx,pattern   ; [EBX] points to pattern string
  1025.         call  fillpattern   ; define the pattern
  1026.         sub   ebx,8         ; [EBX] points to box corner data
  1027.         call  fillbox       ; draw a patterned box
  1028.  
  1029.  
  1030. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1031.  
  1032. FORCEGMODE:    force ASM32 to use one particular graphics mode
  1033.                this is handy for two-monitor systems
  1034. Source:        defgmode.asm
  1035.  
  1036. Call with:     AL = graphics mode to use
  1037.                forcegmode does not change the actual screen mode; what
  1038.                it does is to force ASM32's central graphics control
  1039.                to ignore the system mode.  Call defgmode to restore
  1040.                ASM32's internal flags to the default state.
  1041. Returns:       nothing
  1042. Uses:          nothing
  1043. Supports:      all ASM32 graphics modes (256-color modes not tested)
  1044. Example:
  1045.  
  1046. include model.inc
  1047.  
  1048. extrn   modecolor:near, modemono:near
  1049. extrn   forcegmode:near, gcolor:near, defgmode:near
  1050.  
  1051. include dataseg.inc
  1052. gtext   db 'Graphics mode',0
  1053. gpos    dd 0                   ; 2 words of zeros to position text
  1054. ttext   db 'Text mode',0
  1055. @curseg ends
  1056.  
  1057. include codeseg.inc
  1058.         .
  1059. ; I want text on the monochrome screen and 16-color graphics on the EGA
  1060.         call   modecolor       ; switch to color monitor
  1061.         mov    ax,10h          ; set up graphics mode
  1062.         int    10h
  1063.         mov    al,10h          ; tell ASM32 to use mode 10h
  1064.                                ; use AL = 13h for VGA 256-color modes
  1065.                                ; use AL = 8 for Hercules (including InColor)
  1066.         call   forcegmode      ; best to do this after the mode change
  1067.         call   modemono        ; switch back to the monochrome monitor
  1068.         mov    ax,010Ch        ; blue background, red foreground
  1069.         call   gcolor
  1070.         lea    esi,gtext       ; point to graphics message
  1071.         lea    edx,gpos        ; positioned at upper left corner
  1072.         call   gprint          ; prints on EGA in graphics mode
  1073.  
  1074.         lea    esi,ttext       ; point to text message
  1075.         xor    dx,dx           ; upper left corner of text screen
  1076.         mov    ah,7            ; normal color
  1077.         call   tprint          ; display message on monochrome monitor
  1078.         .
  1079.         .
  1080. ; sometime later, all done with this setup
  1081.         call   defgmode        ; clear ASM32's internal graphics flags
  1082.  
  1083.  
  1084. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1085.  
  1086. GBASEADDRESS:  change ASM32 graphics base address
  1087. Source:        gbaseadr.asm ($graph.asm)
  1088.  
  1089. Call with:     EAX = base address for alternate graphics buffer
  1090.                if EAX = 0, default base segment is restored
  1091.                GBaseAddress may be used to create and update off-screen
  1092.                graph images, thus simulating multiple screen pages.
  1093. Returns:       nothing
  1094. Uses:          nothing
  1095. Supports:      mode 04h, 05h, HGraph (monochrome only), 40h, 11h, 13h
  1096.  
  1097.                buffer size requirements:
  1098.  
  1099.                 mode 04h, 05h    16384 bytes
  1100.                 HGraph, 40h      32768 bytes
  1101.                 mode 11h         38400 bytes
  1102.                 mode 13h         64000 bytes
  1103.  
  1104.                 You must call GBaseAddress AFTER switching the system to
  1105.                 graphics mode, or it will not work; you must also call
  1106.                 GBaseAddress with EAX = 0 before changing from one graphics
  1107.                 mode to another, or the default base address may get messed
  1108.                 up.
  1109. Example:
  1110.  
  1111. public myprog
  1112.  
  1113. include codeseg.inc
  1114.  
  1115. extrn  gbaseaddress:near, drawbox:near
  1116.  
  1117. ; data
  1118. boxdata dw 0,0,319,199
  1119.  
  1120. screen1 db 64000 dup (0)     ; second screen for mode 13h
  1121.  
  1122. ; code
  1123. myprog proc
  1124. ; mode 13h, 320x200x256 colors
  1125.        mov     ax,13h
  1126.        int     10h
  1127.  
  1128. ; use alternate buffer
  1129.        lea     eax,screen1
  1130.        call    gbaseaddress
  1131.        lea     ebx,boxdata
  1132.        call    drawbox
  1133.  
  1134. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1135.  
  1136. GCENTER:       centers a string on a graphics screen
  1137. Source:        gcenter.asm (gprint.asm, $graph.asm, strlen.asm, f8x14.asm)
  1138.  
  1139. GCENTERX:      centers a double-width string on a graphics screen
  1140. Source:        gcenterx.asm (gprintx.asm, $graph.asm, strlen.asm, f8x14.asm)
  1141.  
  1142. Call with:     ESI pointing to the string to print
  1143.                EDX pointing to x- and y-coordinates
  1144.                the x-coordinate is a placeholder; GCenter calculates the
  1145.                correct x value before calling GPrint.
  1146.  
  1147.                Colors, drawmodes and character sizes are the same as
  1148.                for GPrint or GPrintX.
  1149. Returns:       x = calculated x-coordinate
  1150. Uses:          nothing; all registers and flags are saved.
  1151. Supports:      all ASM32 graphics modes
  1152. Example:
  1153.  
  1154. include codeseg.inc
  1155.  
  1156. extrn   gcenter:near
  1157.  
  1158. ; data
  1159. x       dw ?
  1160. y       dw 2               ; print graph title 2 pixels down from the top
  1161. title   db 'Graph title',0
  1162.  
  1163. ; code
  1164.         .
  1165.         .
  1166.         lea    esi,title    ; ESI points to string
  1167.         lea    edx,x        ; point to coordinates
  1168.         call   gcenter      ; print the string, centered horizontally
  1169.  
  1170.  
  1171. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1172.  
  1173. GCLEAR:        clears the active portion of a graphics screen
  1174.                uses background color
  1175. Source:        gclear.asm ($graph.asm, $horiz.asm, others)
  1176.  
  1177. Call with:     no parameters
  1178. Returns:       nothing
  1179. Uses:          nothing
  1180. Supports:      all ASM32 graphics modes
  1181. Example:
  1182.  
  1183. include codeseg.inc
  1184.  
  1185. extrn   gclear:near
  1186.  
  1187. ; code
  1188.         .
  1189.         .
  1190.         .
  1191.         call  gclear
  1192.  
  1193. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1194.  
  1195. GCOLOR:        update color used by ASM32 graphics
  1196. Source:        gcolor.asm ($graph.asm)
  1197.  
  1198. Call with:     (most modes) AL = foreground color
  1199.                             AH = background color
  1200.                (SVGA32k)    AX = foreground color
  1201.                             high word of EAX = background color
  1202.  
  1203.                for 4-color modes, colors may be 0-3
  1204.                for 16-color modes, colors may be 0-15
  1205.                for 256-color modes, colors may be 0-255
  1206.                for 32k-color modes, colors may be 0-32767 (see Color32k)
  1207.  
  1208. Returns:       nothing
  1209. Uses:          nothing
  1210. Supports:      all color graphics modes and mode 0Fh
  1211.                GColor is ignored by 2-color modes
  1212. Example:
  1213.  
  1214. include codeseg.inc
  1215.  
  1216. extrn   gcolor:near
  1217.  
  1218. ; code
  1219.         .
  1220.         .
  1221.         .
  1222.         mov   ah,bcolor      ; background color
  1223.         mov   al,fcolor      ; foreground color
  1224.         call  gcolor
  1225.  
  1226.  
  1227. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1228.  
  1229. GCOPY:         copies one page of graphics memory to another
  1230. Source:        gcopy.asm ($graph.asm)
  1231.  
  1232. Call with:     BH = frompage
  1233.                BL = topage
  1234. Returns:       CF = error flag
  1235.                 if CF = 0, no error
  1236.                 if CF = 1, bad page number or frompage = topage
  1237. Uses:          CF
  1238. Supports:      Hercules and InColor (with Use64k)
  1239.                EGA/VGA modes 0Dh, 0Eh, 0Fh, 10h
  1240.                VGA13X [0,1,2]
  1241.                CauseWay extender ONLY
  1242. Example:
  1243.  
  1244. include codeseg.inc
  1245.  
  1246. extrn   gcopy:near
  1247.  
  1248. ; code
  1249.         .
  1250.         .
  1251.         .
  1252.         mov   bx,0001h       ; copy from page 0 to page 1
  1253.         call  gcopy
  1254.         jc    bad_page       ; uh oh, pages not supported
  1255.  
  1256.  
  1257. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1258.  
  1259. GCURSOR:       simulate text-mode cursor on graphics screen
  1260. GUCURSOR:      simulate underscore cursor on graphics screen
  1261. Source:        gcursor.asm ($graph.asm)
  1262.  
  1263. Call with:     EDX pointing to x- and y-coordinate word data
  1264.                x and y are the coordinates of the UPPER LEFT corner of
  1265.                a character block.  Note that text characters are
  1266.                8 x-pixels wide and from 8 to 16 y-pixels high.
  1267.  
  1268.                GCursor and GUCursor maintain the simulated cursor while
  1269.                the keyboard type-ahead buffer is empty.  GCursor shape
  1270.                is an underscore when INSERT is off and a larger block
  1271.                when INSERT is on.  GUCursor is an underscore regardless
  1272.                of the state of the INSERT toggle.
  1273. Returns:       nothing
  1274. Uses:          EAX, ECX
  1275. Supports:      all ASM32 graphics modes
  1276. Example:
  1277.  
  1278. include codeseg.inc
  1279.  
  1280. extrn   gcursor:near, getkey:near
  1281.  
  1282. ; data
  1283. x       dw 10,20        ; put the cursor in the character block at (10,20)
  1284.  
  1285. ; code
  1286.         .
  1287.         .
  1288.         .
  1289.         lea   edx,x
  1290.         call  gcursor
  1291.         call  getkey    ; retrieve the key that was pressed
  1292.  
  1293.  
  1294. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1295.  
  1296. GETBITBLOCK:   saves a portion of a graphics screen in memory
  1297. Source:        bitblock.asm ($graph.asm, bb02.asm, bb04.asm, bb06.asm,
  1298.                              bb08.asm, bb10.asm, bb12.asm, bb14.asm,
  1299.                              bb16.asm)
  1300.  
  1301. Call with:     ES:[EDI] pointing to memory buffer for the bit block
  1302.                DS:[EBX] pointing to x & y coordinate data
  1303.  
  1304.                Note that a bit block copied from a 4-plane mode may
  1305.                only be restored to a 4-plane mode; likewise, a bit
  1306.                block saved from a 2-color mode should be restored to
  1307.                a 2-color mode or to a single bit plane of a 16-color
  1308.                mode.
  1309. Returns:       nothing
  1310. Uses:          nothing
  1311. Supports:      all ASM32 graphics modes
  1312.  
  1313.  
  1314.     If you do not intend to support all ASM32 graphics modes, you can
  1315.     call mode-specific BitBlock subroutines to reduce .EXE size.
  1316.     These subroutines use the same calling parameters as GetBitBlock
  1317.     and PutBitBlock:
  1318.  
  1319.  
  1320.     getbb02: mode 04h, 05h, 11h, 40h, HGraph (mono and InColor)
  1321.     getbb06: mode 0Dh, 0Eh, 0Fh, 10h, 12h, SVGA16(0), XMODE16
  1322.     getbb08: mode 13h, 256-color GSCREEN
  1323.     getbb10: VGA13X
  1324.     getbb12: SVGA16
  1325.     getbb14: SVGA256
  1326.     getbb16: SVGA32k
  1327.  
  1328.     putbb02: mode 04h, 05h, 11h, 40h, HGraph (mono only)
  1329.     putbb04: HGraph (InColor only)
  1330.     putbb06: mode 0Dh, 0Eh, 0Fh, 10h, 12h, SVGA16(0), XMODE16
  1331.     putbb08: mode 13h, 256-color GSCREEN
  1332.     putbb10: VGA13X
  1333.     putbb12: SVGA16
  1334.     putbb14: SVGA256
  1335.     putbb16: SVGA32k
  1336.  
  1337. Example on next page
  1338.  
  1339.  
  1340. ; example of GetBitBlock use
  1341.  
  1342. include model.inc
  1343.  
  1344. extrn   bitblockbytes:near, getbitblock:near, putbitblock:near
  1345.  
  1346. include dataseg.inc
  1347. ptr     dd ?                ; use this to save pointer to bit block
  1348. x0      dw 100,43,175,143   ; save from (100,43) to (175,143)
  1349. @curseg ends
  1350.  
  1351. include codeseg.inc
  1352.         .
  1353.         .
  1354.         lea   ebx,x0        ; point to block corners
  1355.         call  bitblockbytes ; calculate byte requirement
  1356.         jc    too_big       ; error control
  1357.         mov   ebx,eax
  1358.         sys   GetMemNear
  1359.         jc    no_memory     ; more error control
  1360.         mov   ptr,esi       ; save near address of bit block
  1361.         mov   edi,esi       ; EDI points to buffer
  1362.         lea   ebx,x0        ; EBX points to coordinate data
  1363.         call  getbitblock
  1364.         .
  1365.         .
  1366.  
  1367. ; later . . .
  1368.         lea   ebx,x0        ; put the bit block back where you found it
  1369.         mov   edi,ptr       ; EDI points to buffer
  1370.         call  putbitblock
  1371.  
  1372.  
  1373. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1374.  
  1375. GETBITPLANE:   saves one plane of a bit block in memory
  1376. Source:        small & medium: bitplane.asm ($graph.asm, bb02.asm, bb04.asm
  1377.                                bb06.asm, bb08.asm, bb10.asm, bb12.asm,
  1378.                                bb14.asm)
  1379.  
  1380. Call with:     ES:[EDI] pointing to memory buffer for the bit block
  1381.                DS:[EBX] pointing to x & y coordinate data
  1382.                AL = plane number to save
  1383.                valid plane numbers are 0 - 3 in 16-color modes
  1384.                                        0 & 2 in EGA monochrome mode
  1385.  
  1386.                In 16-color modes, EGA/VGA and InColor planes are:
  1387.                 0 = blue, 1 = green, 2 = red, 3 = gray (or intensity)
  1388.                In EGA monochrome mode, plane 0 = normal, plane 2 = blink
  1389.                 or intensity
  1390.                The actual colors each plane represents may change
  1391.                depending on the values in the pallete registers.
  1392.  
  1393. Supports:      all 16-color modes plus EGA monochrome
  1394.                other modes: GetBitPlane works like GetBitBlock
  1395.  
  1396.  
  1397. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1398.  
  1399. GETGSCREEN:    copies entire screen image to RAM
  1400. Source:        gscreen.asm ($graph.asm, $gbytes.asm, $plane.asm)
  1401.  
  1402. Call with:     no parameters
  1403.                GetGScreen allocatess a block of near memory and copies
  1404.                the entire screen to the memory block in ASM32's BitBlock
  1405.                format.  Using BitBlock format allows the use of ASM32's
  1406.                BB???REV, BB16MASK, BB256OVL and PutBitBlock subroutines
  1407.                with the screen image.  You may use either PutBitBlock
  1408.                or PutGScreen to restore the image; the advantage of
  1409.                PutGScreen is speed, because it is optimized for copying
  1410.                the entire screen.
  1411.  
  1412. Returns:       EDI = near address of screen image data
  1413.  
  1414. Supports:      all ASM32 graphics modes
  1415.  
  1416. Uses:          EDI, flags
  1417.  
  1418. Example:       see PutGScreen
  1419.  
  1420. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1421.  
  1422. GETVIEW:       returns a pointer to the current view coordinates for
  1423.                the active page
  1424. Source:        getview.asm ($graph.asm)
  1425.  
  1426. Call with:     no parameters
  1427.                most ASM32 subroutines, except the GPrint series, Gload,
  1428.                GCopy and GSave, limit their activity to the view region.
  1429.                You may use the returned pointer to change the active
  1430.                portion of the screen; be careful not to exceed the maximum
  1431.                x1 and y1 values permitted by the current mode.  Also, x0
  1432.                must always be less than x1 and y0 must always be less than
  1433.                y1.
  1434.                ASM32's defaults are:
  1435.                 x0 = 0
  1436.                 y0 = 0
  1437.                 x1 = xmax
  1438.                 y1 = ymax
  1439.  
  1440.                See also ResetView
  1441.  
  1442. Returns:       EBX pointing to the current view coordinates
  1443. Uses:          EBX
  1444. Supports:      all ASM32 graphics modes and pages
  1445. Example:
  1446.  
  1447. include codeseg.inc
  1448.  
  1449. extrn   getview:near
  1450.  
  1451. x0 EQU word ptr [EBX]
  1452. y0 EQU word ptr 2[EBX]
  1453. x1 EQU word ptr 4[EBX]
  1454. y1 EQU word ptr 6[EBX]
  1455.  
  1456. ; code
  1457.         .
  1458.         .
  1459.         .
  1460.         call   getview
  1461.  
  1462.  
  1463. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1464.  
  1465. GETDOT:        determine pixel value on graphics screen
  1466. Source:        getdot.asm ($graph.asm, $getdot.asm, others)
  1467.  
  1468. Call with:     EBX pointing to pixel coordinate data
  1469. Returns:       if CF = 0, AX = pixel value
  1470.                if CF = 1, pixel coordinates outside active view area
  1471. Uses:          EAX, CF
  1472. Supports:      all ASM32 graphics modes
  1473. Example:
  1474.  
  1475. include codeseg.inc
  1476.  
  1477. extrn   getdot:near
  1478.  
  1479. ; data
  1480. x       dw 10,10             ; pixel at (10,10)
  1481.  
  1482. ; code
  1483.         .
  1484.         .
  1485.         .
  1486.         lea    ebx,x         ; point to pixel coordinates
  1487.         call   getdot        ; get pixel value
  1488.         jc     out_of_bounds ; oops
  1489.  
  1490.  
  1491.  
  1492. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1493.  
  1494. GLOAD:         loads a graphics screen saved as a disk file by GSave
  1495. Source:        gload.asm ($graph.asm, $gbytes.asm, $reset.asm, $plane.asm)
  1496.  
  1497. Call with:     EDX pointing to the name of the file to load
  1498.                the filename must be an ASCIIZ string in low memory
  1499. Returns:       AX = MS-DOS error code
  1500. Uses:          EAX, flags
  1501. Supports:      all ASM32 graphics modes
  1502. Example:
  1503.  
  1504. include codeseg.inc
  1505.  
  1506. extrn   gload:near
  1507.  
  1508. ; data
  1509. filename db 'graph.bin',0
  1510.  
  1511. ; code
  1512.         .
  1513.         .
  1514.         lea   edx,filename
  1515.         call  gload
  1516.  
  1517.  
  1518. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1519.  
  1520. GPAGE:         changes active and displayed graphics page
  1521.                GPage changes ASM32's default graphics page and displays
  1522.                the page.  See also UseGPage and ShowGPage.
  1523. Source:        gpage1.asm ($graph.asm, $herc.asm, gpage.asm)
  1524.  
  1525. Call with:     BL = page number.  See table at start of this GRAPHICS.DOC
  1526.                file.
  1527. Returns:       if CF = 0, no problem
  1528.                if CF = 1, bad page number requested
  1529. Uses:          CF
  1530. Supports:      EGA, VGA, Hercules, InColor: modes with more than one page
  1531. Example:
  1532.  
  1533. include codeseg.inc
  1534.  
  1535. extrn   gpage:near
  1536.  
  1537. ; code
  1538.         .
  1539.         .
  1540.         mov    bl,1          ; use and show page 1
  1541.         call   gpage
  1542.         jc     oops          ; uh oh, wrong mode
  1543.  
  1544. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1545.  
  1546. GPRINT:        prints ASCIIZ string on a graphics screen
  1547. Source:        gprint.asm ($graph.asm, f8x14.asm, $gp00.asm, $gp02.asm,
  1548.                            $gp06.asm, $gp08.asm, $gp10.asm, others)
  1549.  
  1550. Call with:     ESI pointing to the ASCIIZ string
  1551.                EDX pointing to x- and y-coordinate data
  1552.                drawmodes supported by GPrint are:
  1553.                 2 = foreground only; background pixels left alone
  1554.                 1 = foreground and background pixels updated with
  1555.                     current gcolor
  1556.                 0 = foreground color is XORed with the existing screen
  1557.                -1 = like drawmode 1, but foreground and background reversed
  1558.                -2 = like drawmode 2, but uses background color
  1559.                Any pixel position may be specified; does not wrap around
  1560.                from right side of screen to left.  Default character size
  1561.                is 8x8 for CGA modes and modes 0Dh, 0Eh and 13h, 8x14 for
  1562.                others.
  1563.                High ASCII characters are undefined in 8x8 pixel modes
  1564.                unless you call SmallText sometime earlier in the program.
  1565. Returns:       nothing
  1566. Uses:          ECX; all other registers and flags are saved
  1567. Supports:      all ASM32 graphics modes
  1568.                not all drawmodes supported with CGA modes 04h and 05h
  1569. Example:
  1570.  
  1571. include codeseg.inc
  1572.  
  1573. extrn   gprint:near
  1574.  
  1575. ; data
  1576. string  db 'print this, if you will',0
  1577. gpos    dw 0,0                          ; print at upper left corner
  1578.  
  1579. ; code
  1580.         .
  1581.         .
  1582.         .
  1583.         lea   esi,string
  1584.         lea   edx,gpos
  1585.         call  gprint
  1586.  
  1587. additional GPRINT information on next page
  1588.  
  1589. GPRINT will work with user-defined fonts up to 16 pixel rows high in all
  1590. modes with ymax > 200.  GPRINT reads a public data area in FONTDATA.ASM to
  1591. determine the address of the font data, the number of pixel rows per
  1592. character and the byte increment between sucessive character definitions.
  1593. Characters must be 8 pixels wide.
  1594.  
  1595. Use $SetFontData in FONTDATA.ASM to set up user-defined fonts.
  1596.  
  1597. Example:
  1598.  
  1599. include model.inc
  1600.  
  1601. extrn   mload:near
  1602. extrn   $SetFontData:near
  1603.  
  1604. include dataseg.inc
  1605.  
  1606. ; data
  1607.  
  1608. fname   db 'c:\ramfont\italics.fnt',0   ; 8x14 characters
  1609. ; the fonts supplied by Hercules with the Graphics Card Plus and InColor
  1610. ; card are a variety of sizes, but in each font file the byte increment
  1611. ; is always 16 bytes
  1612.  
  1613. @curseg   ends
  1614.  
  1615. include codeseg.inc
  1616.  
  1617. ; code
  1618.         .
  1619.         .
  1620.         lea     edx,fname       ; filename
  1621.         call    mload           ; read file
  1622.         mov     fs,bx           ; font selector
  1623.         xor     eax,eax         ; font offset
  1624.         mov     ebx,2           ; user-defined data
  1625.         mov     dx,100Eh        ; 16 bytes per character, 14-point characters
  1626.         call    $SetFontData    ; set up font pointers etc.
  1627.  
  1628.  
  1629. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1630.  
  1631. GPRINTDOWN:    prints ASCIIZ string vertically on graph screen
  1632. GPRINTUP:      prints ASCIIZ string vertically on graph screen
  1633. Source:        gprint.asm ($graph.asm, f8x14.asm, $gp00.asm, $gp02.asm,
  1634.                            $gp06.asm, $gp08.asm, $gp10.asm, others)
  1635.  
  1636. Call with:     same as GPrint
  1637.                rotates each character 90 degrees and prints from top
  1638.                downward or from bottom upward.  Character size 8x8.
  1639.  
  1640.                Returned data and registers used same as GPrint
  1641. Example:       see GPrint.
  1642.  
  1643.  
  1644. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1645.  
  1646. GPRINTX:       print string on a graphics screen, double width
  1647. GPRINT2X:      print string on a graphics screen, double size
  1648. GPRINTDOWNX:   print string vertically on graph screen, 2x width
  1649. GPRINTDOWN2X:  print string vertically on graph screen, 2x size
  1650. GPRINTUPX:     print string vertically on graph screen, 2x width
  1651. GPRINTUP2X:    print string vertically on graph screen, 2x size
  1652. Source:        gprintx.asm ($graph.asm, f8x14.asm, $gp00.asm, $gp02.asm,
  1653.                             $gp06.asm, $gp08.asm, $gp10.asm, others)
  1654.  
  1655.  
  1656.                Variations of GPrint and GPrintDOWN/GPrintUP;
  1657.                GPrintx, GPrintDOWNx and GPrintUPx print characters
  1658.                which are twice as wide as normal; 2x subroutines
  1659.                print the characters twice as wide and twice as high
  1660.                as normal.
  1661.  
  1662.                Parameters, supported modes and drawmodes are same as
  1663.                GPrint.  GPrintx and GPrint2x also work with user-defined
  1664.                fonts.  See GPrint.
  1665. Example:       see GPrint.
  1666.  
  1667.  
  1668. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1669.  
  1670. GPUTCHR:       print a single character on graphics screen
  1671. Source:        gputchr.asm (gprint.asm)
  1672.  
  1673. Call with:     EDX pointing to (x,y) coordinate data
  1674.                AL = character to print
  1675. Returns:       nothing
  1676. Uses:          ECX
  1677. Supports:      all ASM32 graphics modes
  1678. Example:
  1679.  
  1680. include codeseg.inc
  1681.  
  1682. public  mycode
  1683. extrn   gputchr:near
  1684.  
  1685. ; data
  1686. xy      dw 10,10        ; (x,y) coordinates for character
  1687.  
  1688. ; code
  1689. mycode  proc
  1690. ; program fragment assumes screen in graphics mode
  1691.         .
  1692.         .
  1693.         .
  1694.         lea     edx,xy   ; EDX points to coordinate data
  1695.         mov     al,'A'
  1696.         call    gputchr
  1697.         .
  1698.         .
  1699.         .
  1700.         ret
  1701. mycode  endp
  1702.         end
  1703.  
  1704.  
  1705.  
  1706. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1707.  
  1708. GSAVE:         saves a graphics screen as a disk file
  1709.                does not compress image
  1710. Source:        gsave.asm ($graph.asm, $gbytes.asm, $reset.asm, $plane.asm)
  1711.  
  1712. Call with:     EDX pointing to ASCIIZ filename in low memory
  1713.                disk space requirements vary depending on graphics mode:
  1714.  
  1715.                  HGraph  (mono)       32,768 bytes
  1716.                  HGraph  (InColor)   131,072 bytes
  1717.                  VGA13X(0)            64,000 bytes
  1718.                  VGA13X(1)            76,800 bytes
  1719.                  VGA13X(2)           128,000 bytes
  1720.                  VGA13X(3)           172,800 bytes
  1721.                  XMode16  varies; up to 240,000 bytes
  1722.                  VESA6Ah, SVGA16(0)  240,000 bytes
  1723.                  SVGA16(1)           393,216 bytes
  1724.                  SVGA256(0)          256,000 bytes
  1725.                  SVGA256(1)          307,200 bytes
  1726.                  SVGA256(2)          480,000 bytes
  1727.                  SVGA256(3)          786,432 bytes
  1728.                  04h/05h/06h          16,384 bytes
  1729.                  40h                  32,768 bytes
  1730.                  0Dh                  32,000 bytes
  1731.                  0Eh                  64,000 bytes
  1732.                  0Fh                  56,000 bytes
  1733.                  10h                 112,000 bytes
  1734.                  11h                  38,400 bytes
  1735.                  12h                 153,600 bytes
  1736.                  13h                  64,000 bytes
  1737.  
  1738. Returns:       if CF = 1, AX = MS-DOS error code
  1739.                if CF = 0, no error
  1740. Uses:          AX, flags
  1741. Supports:      all ASM32 graphics modes
  1742. Example:
  1743.  
  1744. include codeseg.inc
  1745.  
  1746. extrn   gsave:near
  1747.  
  1748. ; data
  1749. filename db 'graph.bin',0
  1750.  
  1751. ; code
  1752.         .
  1753.         .
  1754.         .
  1755.         lea   edx,filename        ; point to ASCIIZ filename
  1756.         call  gsave               ; save graph
  1757.         jc    oops                ; do some error control if problem
  1758.  
  1759. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1760.  
  1761. LINEPATTERN:   defines an optional pattern for DrawLine and DrawBox
  1762. Source:        lpattern.asm ($graph.asm)
  1763.  
  1764. Call with:     EBX pointing to an ASCIIZ string of up to 8 characters.
  1765.                The bit patterns in each character are used to make dashed
  1766.                or dotted lines. For drawmodes > 0, each pixel in the line
  1767.                is updated with the foreground color if the corresponding
  1768.                bit in the bit pattern is 1.  If the bit in the bit pattern
  1769.                is 0, the corresponding pixel in the line is treated as a
  1770.                background pixel.  LinePattern must be called before each
  1771.                call to a subroutine in drawline.obj if you want the line
  1772.                pattern to be used.
  1773.  
  1774.                drawmodes supported are:
  1775.                (monochrome modes)
  1776.                 2 = update foreground pixels only
  1777.                 1 = update foreground and background pixels
  1778.                 0 = XOR the foreground color with the existing image
  1779.                -1 = like drawmode 1, but foreground and background colors
  1780.                     are reversed
  1781.                -2 = like drawmode 2, but foreground and background colors
  1782.                     are reversed
  1783.                (color modes)
  1784.                same as monochrome, plus:
  1785.                 3 = OR the foreground pixels with the pre-existing screen
  1786.                -3 = OR the background pixels with the pre-existing screen
  1787.                 4 = AND the foreground pixels with the pre-existing screen
  1788.                -4 = AND the background pixels with the pre-existing screen
  1789.  
  1790. Returns:       nothing
  1791. Uses:          nothing
  1792. Supports:      all ASM32 graphics modes
  1793. Example:
  1794.  
  1795. include codeseg.inc
  1796.  
  1797. extrn   linepattern:near, drawline:near
  1798.  
  1799. ; data
  1800. x0      dw 25,10,301,97          ; line endpoints at (25,10) & (301,97)
  1801. pattern db 4 dup(32,64),0        ; 8 bytes past x0
  1802.  
  1803. ; code
  1804.         .
  1805.         .
  1806.         lea   ebx,pattern        ; EBX points to bit pattern
  1807.         call  linepattern        ; let drawline know what pattern to use
  1808.         sub   ebx,8              ; point to line endpoint data
  1809.         call  drawline           ; draw a patterned line
  1810.  
  1811. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1812.  
  1813. LOADPCX:       reads a .PCX-format file from disk and unpacks to screen
  1814. Source:        loadpcx.asm ($graph.asm, color16.asm, fopen.asm, fseek.asm,
  1815.                             fget.asm, fgetchr.asm, $plane.asm, $reset.asm)
  1816.  
  1817. Call with:     [EDX] pointing to ASCIIZ filename of .PCX file.
  1818.                LoadPCX assumes that the video system is in an appropriate
  1819.                mode for the image; see PCXInfo (GRAPHICS.DOC).
  1820.                The dimensions of the image in the .PCX file need not
  1821.                match the screen dimensions exactly; any 16-color image
  1822.                may be loaded to a 16-color screen; if the image is too
  1823.                large for the video buffer, either the upper left portion
  1824.                of the image is unpacked, or you may re-size the video buffer
  1825.                (see BufferDim) to fit the image.  Any 2-color ("monochrome")
  1826.                image may be loaded to any monochrome screen.
  1827.  
  1828.                256-color PCX files intended for the standard 320x200
  1829.                mode 13h may be loaded to the non-standard VGA13X modes.
  1830.                In VGA13X modes with 400 or 480 vertical pixel rows,
  1831.                a 320x200 image is stretched to fit screen proportions.
  1832. Returns:       if CF = 0, no error
  1833.                if CF = 1, AX = DOS error code
  1834. Uses:          AX, flags
  1835. Supports:      All ASM32 graphics modes EXCEPT:
  1836.                   mode 04h, 05h (no palette)
  1837.                   mode 0Fh, EGA monochrome (not tested)
  1838.                   SVGA32k (is there a standard .PCX format for this mode?)
  1839. Example:       see PCXInfo and BufferDim         
  1840.                
  1841.  
  1842.  
  1843. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1844.  
  1845. PUTBITBLOCK:   restores bit block saved by GetBitBlock
  1846. PUTBITPLANE:   restores bit plane saved by GetBitPlane
  1847. Source:        same as GetBitBlock or GetBitPlane
  1848.  
  1849. Call with:     DS:[EBX] pointing to upper left corner coordinates
  1850.                ES:[EDI] pointing to buffer with stored bit block
  1851.                 PutBitPlane: AL = plane number
  1852.                 valid plane numbers for 16-color modes are 0 - 3
  1853.                                     for EGA mode 11h       0 & 2
  1854.  
  1855.                Drawmodes supported are:
  1856.                 mode 13h, VGA13x, SVGA256:
  1857.                  0 = XOR the bit block with the existing screen (VGA13x only)
  1858.                  1 = replace existing screen area with bit block
  1859.                  2 = replace existing screen with non-zero pixels
  1860.                      in bit block
  1861.  
  1862.                 HGraph (InColor):
  1863.                  4 = AND the bit block with the existing screen
  1864.                  3 = OR the bit block with the existing screen
  1865.                  1,2 = replace existing screen area with bit block
  1866.                  0 = XOR the bit block with the existing image
  1867.                 -1,-2 = replace existing screen area with inverse bit block
  1868.  
  1869.                 16-color EGA/VGA-type modes and mode 0Fh:
  1870.                  same as InColor, plus:
  1871.                 -3 = OR the inverse bit block with the existing screen
  1872.                 -4 = AND the inverse bit block with the existing screen
  1873.  
  1874.                 mode 04h, 05h, 06h, 40h, HGraph (mono), 11h:
  1875.                  4, 1, 0, -1 same as InColor
  1876.                  2, 3 = combine non-zero pixels in the bit block with the
  1877.                         pre-existing image
  1878.                 -2 = combine non-zero pixel in the inverse bit block with
  1879.                      the pre-existing screen image
  1880.  
  1881.                Most PutBitBlock code ignores View limits (see GetView)
  1882.                but BB08.ASM, BB10.ASM and BB14.ASM (for 256-color modes)
  1883.                clip PutBitBlock operations at View boundaries.
  1884.  
  1885. Returns:       nothing
  1886. Uses:          nothing
  1887. Supports:      all ASM32 graphics modes
  1888. Example:       see GetBitBlock
  1889.  
  1890.  
  1891. bit block formats explained on following pages
  1892.  
  1893.  
  1894. ; BIT BLOCK FORMATS
  1895.  
  1896. ; mode 04h, 05h, 06h Hercules monochrome, 11h, and bit planes
  1897. ;
  1898. ; the first word in the buffer is the number of pixel rows (vertical)
  1899. ; in the bit block; the second word is the number of bytes per screen row;
  1900. ; the fifth byte is a bit mask for the last byte of each pixel row.
  1901. ; The bit mask = 0FFh for byte-aligned bit blocks.
  1902.  
  1903. bblock  dw 15,5              ; 15 rows, 5 bytes per row
  1904.         db 11111110b         ; bit mask for right end of pixel row
  1905.                              ; bit block data follows:
  1906.                              ;  15 rows, 5 bytes per row
  1907.         db 00000000b,10000000b,00000000b,10000000b,00000010b
  1908.         db 00000001b,11000000b,00000001b,11000000b,00000110b
  1909.         db 00000011b,11100000b,00000011b,11100000b,00001100b
  1910.         db 00000111b,01110000b,00000111b,01110000b,00011000b
  1911.         db 00001110b,00111000b,00001110b,00111000b,00110000b
  1912.         db 00011100b,00011100b,00011100b,00011100b,01100000b
  1913.         db 00000001b,11000000b,00000001b,11000000b,11000000b
  1914.         db 00000001b,11000000b,00000001b,11000000b,01100000b
  1915.         db 00000001b,11000000b,00000001b,11000000b,00110000b
  1916.         db 00000001b,11000000b,00000001b,11000000b,00011000b
  1917.         db 00000001b,11000000b,00000001b,11000000b,00001100b
  1918.         db 00000001b,11000000b,00000001b,11000000b,00000110b
  1919.         db 00000001b,11000000b,00000001b,11000000b,00000010b
  1920.         db 00000001b,11000000b,00000001b,11000000b,00000000b
  1921.         db 00000001b,11000000b,00000001b,11000000b,00000000b
  1922.  
  1923. ; 16-color modes: 0Dh, 0Eh, 10h, 12h, 6Ah, xmode16, InColor:
  1924. ; same as above, except there are 4 planes of bit block data
  1925. ; i. e., 4 groups of 15-row, 5-byte data; plane 3 is the first
  1926. ; block, followed by planes 2, 1, and 0.
  1927.  
  1928. ; EGA monochrome mode: 0Fh
  1929. ; similar to 16-color modes, but there are only 2 groups of bit
  1930. ; block data instead of 4
  1931.  
  1932.  
  1933. ; 256-color modes on next page
  1934.  
  1935.  
  1936. ; BIT BLOCK FORMATS
  1937.  
  1938. ; All 256-color modes: no bit mask in the bit block header
  1939.  
  1940. red     equ 12                    ; bright red
  1941. blue    equ 1                     ; blue
  1942.  
  1943. bblock  dw 12,5                   ; 12 rows, 5 bytes per row
  1944.         db red, red, blue,red, red
  1945.         db red, blue,red, blue,red
  1946.         db blue,red, red, red, blue
  1947.         db red, red, blue,red, red
  1948.         db red, blue,red, blue,red
  1949.         db blue,red, red, red, blue
  1950.         db red, red, blue,red, red
  1951.         db red, blue,red, blue,red
  1952.         db blue,red, red, red, blue
  1953.         db red, red, blue,red, red
  1954.         db red, blue,red, blue,red
  1955.         db blue,red, red, red, blue
  1956.  
  1957.  
  1958.  
  1959. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  1960.  
  1961. PUTDOT:        change a pixel on a graphics screen
  1962. Source:        putdot.asm ($graph.asm, $putdot.asm, others)
  1963.  
  1964. Call with:     EBX pointing to x & y coordinates
  1965.                Drawmodes supported are:
  1966.                (monochrome)
  1967.                 1 = set pixel
  1968.                 0 = toggle pixel
  1969.                -1 = erase pixel
  1970.  
  1971.                (color modes)
  1972.                 3 = OR foreground color with pre-existing pixel
  1973.                 1, 2 = replace pixel with foreground color
  1974.                 0 = XOR foreground color with pre-existing pixel
  1975.                -1, -2 = replace pixel with background color
  1976.                -3 = OR background color with pre-existing pixel
  1977. Returns:       if CF = 0, no error
  1978.                if CF = 1, pixel coordinates outside active view area
  1979. Uses:          CF; all other registers and flags are saved
  1980. Supports:      all ASM32 graphics modes
  1981. Example:
  1982.  
  1983. include codeseg.inc
  1984.  
  1985. extrn   putdot:near
  1986.  
  1987. ; data
  1988. extrn   drawmode:byte
  1989. x       dw 100,117            ; pixel at x = 100, y = 117
  1990.  
  1991. ; code
  1992.         .
  1993.         .
  1994.         .
  1995.         mov   drawmode,1      ; use foreground color
  1996.         lea   ebx,x           ; point to pixel coordinates
  1997.         call  putdot
  1998.  
  1999.  
  2000.  
  2001. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2002.  
  2003. PUTGSCREEN:    copies screen image in RAM to video hardware
  2004. Source:        gscreen.asm ($graph.asm, $gbytes.asm, $plane.asm)
  2005.  
  2006. Call with:     EDI = near address of screen image data
  2007.                PutGScreen copies a screen image saved by GetGScreen to
  2008.                the video adapter's screen buffer.  PutGScreen also works
  2009.                with a screen image saved by GetBitBlock, if the "BitBlock"
  2010.                is the entire screen.  You may use either PutBitBlock
  2011.                or PutGScreen to restore the image; the advantage of
  2012.                PutGScreen is speed, because it is optimized for copying
  2013.                the entire screen.
  2014.  
  2015. Returns:       if CF = 0, no error
  2016.                if CF = 1, screen image not correct size or format
  2017.  
  2018. Supports:      all ASM32 graphics modes
  2019.  
  2020. Uses:          flags
  2021.  
  2022. Example:
  2023.  
  2024.  
  2025. extrn    getgscreen:near
  2026. extrn    putgscreen:near
  2027.  
  2028. include dataseg.inc
  2029. screen_ptr dd ?
  2030. xy         dw 0,0
  2031. @curseg ends
  2032.  
  2033. include codeseg.inc
  2034. ; program fragment assumes DS:dataseg
  2035. ; and screen in graphics mode
  2036.        call     getgscreen
  2037.        mov      screen_ptr,edi
  2038.        .
  2039.        .
  2040.        .
  2041. ; some time later...
  2042.        mov      edi,screen_ptr
  2043.        call     putgscreen           ; restore screen image
  2044.        jc       got_a_problem
  2045.        .
  2046.        .
  2047.  
  2048. ; error handling code
  2049. got_a_problem:
  2050.  
  2051.  
  2052.  
  2053. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2054.  
  2055. PCXINFO:       read vital information from .PCX-format graphics file
  2056. Source:        pcxinfo.asm
  2057.  
  2058. Call with:     [EDX] pointing to ASCIIZ name of .PCX file
  2059. Returns:       [EBX] pointing to PCX information data structure:
  2060.  
  2061.                pcx_info struc
  2062.                horiz    dw 0
  2063.                vert     dw 0
  2064.                colors   dw 0
  2065.                planes   db 0
  2066.                xpixels  dw 0
  2067.                ypixels  dw 0
  2068.                pcx_info ends
  2069.  
  2070.                horiz and vert are screen dimensions
  2071.                colors: 16 for EGA/VGA 16-color modes, 256 for 256-color modes
  2072.                planes: number of bit planes encoded
  2073.                        4 for 16-color modes, 1 for monochrome, CGA or mode 13h
  2074.                xpixels: horizontal image size
  2075.                ypixels: vertical image size
  2076.  
  2077.  
  2078.  
  2079. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2080.  
  2081. RESETVIEW:     restores default view area on active graphics page and
  2082.                returns a pointer to the view data
  2083. Source:        view.asm ($graph.asm)
  2084.  
  2085. Call with:     no parameters
  2086.                ResetView restores the default full screen view area.
  2087.                The far pointer returned points to ASM32's data area in
  2088.                $graph.obj for the active graphics page's view coordinates.
  2089. Returns:       EBX pointing to the active page's view data.
  2090. Uses:          EBX; all other registers and flags are saved
  2091. Supports:      all ASM32 graphics modes
  2092. Example:
  2093.  
  2094. include codeseg.inc
  2095.  
  2096. extrn   resetview:near
  2097.  
  2098. x0 EQU word ptr [EBX]
  2099. y0 EQU word ptr 2[EBX]
  2100. x1 EQU word ptr 4[EBX]
  2101. y1 EQU word ptr 6[EBX]
  2102.  
  2103. ; code
  2104.         .
  2105.         .
  2106.         .
  2107.         call  resetview
  2108.  
  2109.  
  2110.  
  2111. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2112.  
  2113. SCREENORIGIN:  control position of re-sized video buffer on screen
  2114.                see also BufferDim in GRAPHICS.DOC
  2115. Source:        scrnorig.asm
  2116.  
  2117. Call with:     EBX pointing to upper-left coordinates of logical
  2118.                video buffer to be displayed at upper-left corner of screen.
  2119. Returns:       nothing
  2120. Uses:          nothing
  2121. Supports:      Screen modes re-sized with BufferDim:
  2122.                 EGA/VGA 16-color modes
  2123.                 VGA13x modes
  2124.                 VESA SVGA modes
  2125. Example:       see BufferDim
  2126.  
  2127.  
  2128. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2129.  
  2130. SHOWGPAGE:     change graphics page displayed on screen
  2131.                See also UseGPage and GPage.
  2132. Source:        gpage1.asm ($graph.asm, $herc.asm)
  2133.  
  2134. Call with:     BL = page number
  2135. Returns:       Carry Flag = error code
  2136.                if CF = 0, no error
  2137.                if CF = 1, bad page number
  2138. Uses:          CF
  2139. Supports:      HGraph (mono and InColor), modes 0Dh, 0Eh, 0Fh, 10h, VGA13X
  2140. Example:
  2141.  
  2142. include codeseg.inc
  2143.  
  2144. extrn   showgpage:near
  2145.  
  2146. ; code
  2147.         .
  2148.         .
  2149.         .
  2150.         mov   bl,1           ; show page 1
  2151.         call  showgpage
  2152.         jc    no_page_1      ; no page 1 for this mode
  2153.  
  2154. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2155.  
  2156. SHOWGPLANE:    show one or more planes of multi-plane EGA/VGA screen
  2157. Source:        gplane.asm ($graph.asm)
  2158.  
  2159. Call with:     AL = plane mask
  2160.                Bits set in the plane mask correspond to the plane displayed.
  2161.                ASM32's default mask is 00001111b, enabling all 4 planes.
  2162. Returns:       CF = error flag
  2163.                if CF = 0, no error
  2164.                if CF = 1, bad plane mask or graphics mode
  2165. Uses:          CF
  2166. Supports:      EGA & VGA 16-color modes, including VESA 6Ah, xmode16
  2167.                    and SVGA16
  2168.                EGA monochrome: planes 0 and 2
  2169.                    (mask = 00000101b for both planes)
  2170.                Hercules InColor
  2171. Example:
  2172.  
  2173. include codeseg.inc
  2174.  
  2175. extrn   showgplane:near
  2176.  
  2177. ; code
  2178.         .
  2179.         .
  2180.         .
  2181.         mov   al,00000101b      ; show planes 0 and 2
  2182.         call  showgplane
  2183.         jc    error             ; error control
  2184.  
  2185.  
  2186.  
  2187. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2188.  
  2189. SMALLTEXT:     change GPrint, GPrintX and GPrint2X default to 8x8 characters
  2190.                in Hercules and modes 10h, 11h, 12h; makes 8x8-size
  2191.                high ASCII characters available to GPrint in all modes
  2192. Source:        smalltxt.asm (f8x8.asm, $graph.asm)
  2193.  
  2194. STDTEXT:       restore GPrint default characters (see GPrint)
  2195. Source:        stdtext.asm (f8x14.asm, fontdata.asm)
  2196.  
  2197. Call with:     no parameters
  2198. Returns:       nothing
  2199. Uses:          nothing; all registers and flags are saved
  2200. Example:
  2201.  
  2202. include codeseg.inc
  2203.  
  2204. extrn   smalltext:near, stdtext:near
  2205.  
  2206. ; code
  2207.         .
  2208.         .
  2209.         .
  2210. ; make GPrint use the small 8x8 characters
  2211. ; make sure high ASCII characters are available
  2212.         call   smalltext
  2213.         .
  2214.         .
  2215.  
  2216. ; sometime later, I want to use larger 8x14 characters
  2217.         call   stdtext
  2218.  
  2219.  
  2220. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2221.  
  2222. SYS2UC:        convert system coordinates to user-defined coordinates
  2223. Source:        uc2sys.asm ($graph.asm)
  2224.  
  2225. Call with:     EBX pointing to (x0,y0,x1,y1) system coordinates
  2226. Returns:       EBX pointing to (x0,y0,x1,y1) user-defined coordinates
  2227.  
  2228.                UCINIT, SYS2UC and UC2SYS allow the programmer to define a
  2229.                graph coordinate system to fit the data, and converts
  2230.                the system's y-orientation from top-to-bottom to the more
  2231.                familiar bottom-to-top
  2232.                SYS2UC and US2SYS maintain a separate data area for converted
  2233.                coordinates; the input coordinates are not changed
  2234. Uses:          EBX
  2235. Supports:      all ASM32 graphics modes; user-defined coordinates
  2236.                from -32767 to +32767; see also UCINIT
  2237. Example:       see UCINIT
  2238.  
  2239.  
  2240.  
  2241. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2242.  
  2243. UC2SYS:        convert user-defined coordinates to system coordinates
  2244. Source:        uc2sys.asm ($graph.asm)
  2245.  
  2246. Call with:     EBX pointing to (x0,y0,x1,y1) user-defined coordinates
  2247. Returns:       EBX pointing to (x0,y0,x1,y1) system coordinates
  2248.  
  2249.                UCINIT and UC2SYS allow the programmer to define a
  2250.                graph coordinate system to fit the data, and converts
  2251.                the system's y-orientation from top-to-bottom to the more
  2252.                familiar bottom-to-top
  2253.                US2SYS maintains a separate data area for converted
  2254.                coordinates; the input coordinates are not changed
  2255. Uses:          EBX
  2256. Supports:      all ASM32 graphics modes; user-defined coordinates
  2257.                from -32767 to +32767; see also UCINIT
  2258. Example:       see UCINIT
  2259.  
  2260.  
  2261. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2262.  
  2263. UCINIT:        specify user-defined coordinates
  2264. Source:        uc2sys.asm ($graph.asm)
  2265.  
  2266. Call with:     EBX pointing to desired xmin, ymin, xmax, ymax
  2267.                coordinates (xmax-xmin < 32767, ymax-ymin < 32767)
  2268.                ASM32's default user coordinates are (0,0,1000,1000)
  2269. Returns:       nothing
  2270. Uses:          nothing
  2271. Example:
  2272.  
  2273. ; I'm plotting a graph on the screen with x-axis data from 1983 to 2007
  2274. ; and y-axis data from -72 to 140
  2275. ; I'll leave some space on each side for titles, etc.
  2276.  
  2277. extrn   ucinit:near, uc2sys:near
  2278. extrn   drawbox:near
  2279.  
  2280. include dataseg.inc
  2281. x0      dw 1975    ; xmin
  2282. y0      dw -80     ; ymin
  2283. x1      dw 2014    ; xmax
  2284. y1      dw 148     ; ymax
  2285. @curseg ends
  2286.  
  2287. include codeseg.inc
  2288.         .
  2289.         .
  2290.         .
  2291. ; establish coordinates
  2292.         lea     ebx,x0
  2293.         call    ucinit
  2294.  
  2295. ; draw a box around the graph
  2296.         mov     x0,1983
  2297.         mov     y0,-72
  2298.         mov     x1,2007
  2299.         mov     y1,140
  2300.         lea     ebx,x0
  2301.         call    uc2sys
  2302.         call    drawbox
  2303.  
  2304. ; convert mouse position to user coordiantes
  2305.         mov     ax,3
  2306.         int     33h
  2307.         shl     edx,16
  2308.         mov     dx,cx            ; EDX = x:y mouse coordinates
  2309.         push    edx              ; EDX on stack at SS:ESP
  2310.         mov     ebx,esp          ; EBX points to (x,y) - assumes DS = SS
  2311.         call    sys2uc           ; convert to user coordinate system
  2312.         pop     edx              ; fix the stack
  2313.                                  ; UserX = word at [ebx]
  2314.                                  ; UserY = word at 2[ebx]
  2315.  
  2316. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2317.  
  2318. USEGPAGE:      changes active graphics page used by ASM32
  2319.                does not change page displayed (see GPage and ShowGPage)
  2320. Source:        gpage.asm ($graph.asm, $herc.asm)
  2321.  
  2322. Call with:     BL = page number
  2323. Returns:       if CF = 0, no error
  2324.                if CF = 1, bad page number
  2325. Uses:          CF
  2326. Supports:      HGraph (mono and InColor) with Use64k
  2327.                EGA and VGA: modes with more than one page
  2328. Example:
  2329.  
  2330. include codeseg.inc
  2331.  
  2332. extrn   usegpage:near
  2333.  
  2334. ; code
  2335.         .
  2336.         .
  2337.         mov   bl,1
  2338.         call  usegpage
  2339.         jc    oops
  2340.  
  2341.  
  2342.  
  2343. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2344.  
  2345. USEGSCREEN:    use GSCREEN bitblock as screen buffer
  2346. Source:        usegscrn.asm ($graph.asm)
  2347.  
  2348. Call with:     EDI = near address of GSCREEN or BitBlock
  2349.                UseGScreen forces ASM32 graphics subroutines to write to
  2350.                the bitblock at [EDI] instead of to the video memory.  Any
  2351.                256-color bitblock in ASM32's bitblock format may be used
  2352.                as the GSCREEN buffer; the bitblock, with its dimensions,
  2353.                becomes the effecive screen buffer.  ASM32 subroutines will
  2354.                write to & read from the bitblock as though it were video
  2355.                memory.  Use ASM32's UseDefaultScreen to resume using the
  2356.                video hardware.  You will need to call UseDefaultScreen
  2357.                before using PutBitBlock or PutGScreen to display the
  2358.                off-screen bitblock.
  2359.  
  2360.                The advantages of using an off-screen video buffer include:
  2361.  
  2362.                ■ Access to RAM is often much faster than to video hardware
  2363.                ■ Your program can update screens or bitblocks invisibly,
  2364.                  using normal ASM32 subroutines
  2365.                ■ You can use a screen buffer larger than your hardware's
  2366.                  video memory.  See example.
  2367.  
  2368. Returns:       nothing
  2369. Uses:          nothing
  2370. Supports:      all 256-color modes
  2371.                all 256-color bitblocks saved in ASM32's bitblock format
  2372.                all ASM32 graphics subroutines except ScreenOrigin,
  2373.                    BufferDim, GPage, GCopy.
  2374.  
  2375.  
  2376.  
  2377. (UseGScreen, examples)
  2378.  
  2379. Example 0:
  2380.  
  2381. extrn   getgscreen:near, putgscreen:near
  2382. extrn   usegscreen:near, usedefaultscreen:near
  2383. extrn   putdot:near
  2384.  
  2385. include dataseg.inc
  2386.  
  2387. xy              dw 10,100            ; screen x,y coordinates
  2388. screen_ptr      dd ?
  2389.  
  2390. @curseg ends
  2391.  
  2392. include codeseg.inc
  2393.         .
  2394.         .
  2395. ; program fragment assumes DS:dataseg
  2396. ; and screen in graphics mode
  2397.         call    getgscreen
  2398.         mov     screen_ptr,edi
  2399.         call    usegscreen           ; use the GSCREEN just created
  2400.                                      ; for all screen updates
  2401.         lea     ebx,xy               ; point to (x,y) coordinates
  2402.         call    putdot               ; updates GSCREEN at (10,100)
  2403.         .
  2404.         .
  2405.         .
  2406. ; some time later...
  2407.         call    usedefaultscreen     ; read from/write to video hardware
  2408.         mov     edi,screen_ptr
  2409.         call    putgscreen           ; restore screen image
  2410.         jc      got_a_problem
  2411.         .
  2412.         .
  2413.  
  2414. ; error handling code
  2415. got_a_problem:
  2416.  
  2417.  
  2418.  
  2419. (UseGScreen, examples)
  2420.  
  2421. Example 1:
  2422.  
  2423. ; create a huge off-screen video buffer
  2424. ; program will get parts of it later to copy to video hardware
  2425.  
  2426. extrn   getgscreen:near, putgscreen:near
  2427. extrn   usegscreen:near, usedefaultscreen:near
  2428. extrn   putdot:near
  2429.  
  2430. include dataseg.inc
  2431.  
  2432. xy              dw 10,100            ; screen x,y coordinates
  2433. screen_ptr      dd ?
  2434.  
  2435. @curseg ends
  2436.  
  2437. include codeseg.inc
  2438.         .
  2439.         .
  2440.         .
  2441. ; create a 1024 x 1024 buffer
  2442. ; need to add 4 bytes for the "bitblocK" header
  2443.         mov     ebx,(1024*1024)+4
  2444. IFDEF   DPMI
  2445. ; DPMI version
  2446.         call    GetMemNear
  2447. ELSE
  2448. ; CauseWay version
  2449.         sys     GetMemNear
  2450. ENDIF
  2451.         mov     screen_ptr,esi
  2452.  
  2453. ; set up bitblock header
  2454.         mov     word ptr [esi],1024  ; x-pixels
  2455.         mov     word ptr 2[esi],1024 ; y-pixels
  2456.         mov     edi,esi
  2457.         call    UseGScreen
  2458.  
  2459. ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2460.  
  2461. VIEWLIMIT:     determine current mode's maximum dimensions
  2462. Source:        view.asm ($graph.asm)
  2463.  
  2464. Call with:     no parameters
  2465. Returns:       EBX pointing to xmax
  2466.                EBX+2 pointing to ymax
  2467. Uses:          EBX
  2468. Supports:      all ASM32 graphics modes
  2469. Example:
  2470.  
  2471. include codeseg.inc
  2472.  
  2473. extrn   viewlimit:near
  2474.  
  2475. ; code
  2476.         .
  2477.         .
  2478.         call  viewlimit
  2479.  
  2480.